package com.example.fireassistant_server.entity;

import lombok.Data;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;

@Table(name = "polyline")
@Entity
@Data
public class PolyLine extends MarkerEntity{

    private String  description;

    // 中心点
    private BigDecimal latitude;
    private BigDecimal longitude;

    private String background_color;


    @ManyToMany(fetch = FetchType.EAGER)
    @Fetch(FetchMode.SUBSELECT)
    @JoinTable(name = "line_point", joinColumns = @JoinColumn(name = "line_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "point_id", referencedColumnName = "id"))
    private List<Point> points;


    @Column(name = "user_id")
    private String userId;


    @ManyToMany(fetch = FetchType.EAGER)
    @Fetch(FetchMode.SUBSELECT)
    @JoinTable(name = "line_file", joinColumns = @JoinColumn(name = "line_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "file_id", referencedColumnName = "id"))
    private List<File> Files;

}
